/// RRTF in Israel 20210310 by Shingo Hamanaka ////

set more off

gen id = _n

tostring H113 H213 H313 H413 H513, replace
******************************************

gen enemy1 =.
replace enemy1 = 0 if H111=="צבא איראן"
replace enemy1 = 1 if H111=="חמאס"
replace enemy1 = 2 if H111=="חיזבאללה"

gen enemy2 =.
replace enemy2 = 0 if H211=="צבא איראן"
replace enemy2 = 1 if H211=="חמאס"
replace enemy2 = 2 if H211=="חיזבאללה"

gen enemy3 =.
replace enemy3 = 0 if H311=="צבא איראן"
replace enemy3 = 1 if H311=="חמאס"
replace enemy3 = 2 if H311=="חיזבאללה"

gen enemy4 =.
replace enemy4 = 0 if H411=="צבא איראן"
replace enemy4 = 1 if H411=="חמאס"
replace enemy4 = 2 if H411=="חיזבאללה"

gen enemy5 =.
replace enemy5 = 0 if H511=="צבא איראן"
replace enemy5 = 1 if H511=="חמאס"
replace enemy5 = 2 if H511=="חיזבאללה"

******************************************

gen area1 =.
replace area1 = 0 if H112=="תל אביב"
replace area1 = 1 if H112=="ליד הגבול"
replace area1 = 2 if H112=="ירושלים"

gen area2 =.
replace area2 = 0 if H212=="תל אביב"
replace area2 = 1 if H212=="ליד הגבול"
replace area2 = 2 if H212=="ירושלים"

gen area3 =.
replace area3 = 0 if H312=="תל אביב"
replace area3 = 1 if H312=="ליד הגבול"
replace area3 = 2 if H312=="ירושלים"

gen area4 =.
replace area4 = 0 if H412=="תל אביב"
replace area4 = 1 if H412=="ליד הגבול"
replace area4 = 2 if H412=="ירושלים"

gen area5 =.
replace area5 = 0 if H512=="תל אביב"
replace area5 = 1 if H512=="ליד הגבול"
replace area5 = 2 if H512=="ירושלים"

******************************************

gen death1 =.
replace death1 = 0 if H113=="0"
replace death1 = 1 if H113=="1"
replace death1 = 2 if H113=="10"
replace death1 = 3 if H113=="100"

gen death2 =.
replace death2 = 0 if H213=="0"
replace death2 = 1 if H213=="1"
replace death2 = 2 if H213=="10"
replace death2 = 3 if H213=="100"

gen death3 =.
replace death3 = 0 if H313=="0"
replace death3 = 1 if H313=="1"
replace death3 = 2 if H313=="10"
replace death3 = 3 if H313=="100"

gen death4 =.
replace death4 = 0 if H413=="0"
replace death4 = 1 if H413=="1"
replace death4 = 2 if H413=="10"
replace death4 = 3 if H413=="100"

gen death5 =.
replace death5 = 0 if H513=="0"
replace death5 = 1 if H513=="1"
replace death5 = 2 if H513=="10"
replace death5 = 3 if H513=="100"

***************************************

gen protected1 = .
replace protected1 = 0 if H114=="חפים מפשע"
replace protected1 = 1 if H114=="העם היהודי"
replace protected1 = 2 if H114=="אזרחי ישראל"
replace protected1 = 3 if H114=="הסדר העולמי"

gen protected2 = .
replace protected2 = 0 if H214=="חפים מפשע"
replace protected2 = 1 if H214=="העם היהודי"
replace protected2 = 2 if H214=="אזרחי ישראל"
replace protected2 = 3 if H214=="הסדר העולמי"

gen protected3 = .
replace protected3 = 0 if H314=="חפים מפשע"
replace protected3 = 1 if H314=="העם היהודי"
replace protected3 = 2 if H314=="אזרחי ישראל"
replace protected3 = 3 if H314=="הסדר העולמי"

gen protected4 = .
replace protected4 = 0 if H414=="חפים מפשע"
replace protected4 = 1 if H414=="העם היהודי"
replace protected4 = 2 if H414=="אזרחי ישראל"
replace protected4 = 3 if H414=="הסדר העולמי"

gen protected5 = .
replace protected5 = 0 if H514=="חפים מפשע"
replace protected5 = 1 if H514=="העם היהודי"
replace protected5 = 2 if H514=="אזרחי ישראל"
replace protected5 = 3 if H514=="הסדר העולמי"

********************************************

gen security1 = .
replace security1 = 0 if H115=="ביטחון ישראל"
replace security1 = 1 if H115=="ביטחון המזרח התיכון"

gen security2 = .
replace security2 = 0 if H215=="ביטחון ישראל"
replace security2 = 1 if H215=="ביטחון המזרח התיכון"

gen security3 = .
replace security3 = 0 if H315=="ביטחון ישראל"
replace security3 = 1 if H315=="ביטחון המזרח התיכון"

gen security4 = .
replace security4 = 0 if H415=="ביטחון ישראל"
replace security4 = 1 if H415=="ביטחון המזרח התיכון"

gen security5 = .
replace security5 = 0 if H515=="ביטחון ישראל"
replace security5 = 1 if H515=="ביטחון המזרח התיכון"



********************************************



gen ally1 = .
replace ally1 = 0 if H116=="No" 
replace ally1 = 1 if H116=="בשיתוף פעולה עם צבא ארצות הברית"

gen ally2 = .
replace ally2 = 0 if H216=="No"
replace ally2 = 1 if H216=="בשיתוף פעולה עם צבא ארצות הברית"

gen ally3 = .
replace ally3 = 0 if H316=="No"
replace ally3 = 1 if H316=="בשיתוף פעולה עם צבא ארצות הברית"

gen ally4 = .
replace ally4 = 0 if H416=="No"
replace ally4 = 1 if H416=="בשיתוף פעולה עם צבא ארצות הברית"

gen ally5 = .
replace ally5 = 0 if H516=="No"
replace ally5 = 1 if H516=="בשיתוף פעולה עם צבא ארצות הברית"


*************************************************
* アウトカム
gen out1 = Q15_1
gen out2 = Q15_3
gen out3 = Q15_5
gen out4 = Q15_7
gen out5 = Q15_9


* Outcome11 (anger against the govermemt) 
gen xang1=0
replace xang1 = 1 if Q15_2_2 == 1
replace xang1 = . if Q15_2_2 == 7
replace xang1 = . if Q15_2_2 == .


gen xang2=0
replace xang2 = 1 if Q15_4_2 == 1
replace xang2 = . if Q15_4_2 == 7
replace xang2 = . if Q15_4_2 == .

gen xang3=0
replace xang3 = 1 if Q15_6_2 == 1
replace xang3 = . if Q15_6_2 == 7
replace xang3 = . if Q15_6_2 == .

gen xang4=0
replace xang4 = 1 if Q15_8_2 == 1
replace xang4 = . if Q15_8_2 == 7
replace xang4 = . if Q15_8_2 == .

gen xang5=0
replace xang5 = 1 if Q15_10_2 == 1
replace xang5 = . if Q15_10_2 == 7
replace xang5 = . if Q15_10_2 == .

* Outcome12 (anxiety about the govermemt) 
gen xanx1=0
replace xanx1 = 1 if Q15_2_2 == 2
replace xanx1 = . if Q15_2_2 == 7
replace xanx1 = . if Q15_2_2 == .

gen xanx2=0
replace xanx2 = 1 if Q15_4_2 == 2
replace xanx2 = . if Q15_4_2 == 7
replace xanx2 = . if Q15_4_2 == .

gen xanx3=0
replace xanx3 = 1 if Q15_6_2 == 2
replace xanx3 = . if Q15_6_2 == 7
replace xanx3 = . if Q15_6_2 == .

gen xanx4=0
replace xanx4 = 1 if Q15_8_2 == 2
replace xanx4 = . if Q15_8_2 == 7
replace xanx4 = . if Q15_8_2 == .

gen xanx5=0
replace xanx5 = 1 if Q15_10_2 == 2
replace xanx5 = . if Q15_10_2 == 7
replace xanx5 = . if Q15_10_2 == .

* Outcome13 （joy for the government）
gen xhappy1 = 0
replace xhappy1 = 1 if Q15_2_2 == 3
replace xhappy1 = . if Q15_2_2 == 7
replace xhappy1 = . if Q15_2_2 == .

gen xhappy2 = 0
replace xhappy2 = 1 if Q15_4_2 == 3
replace xhappy2 = . if Q15_4_2 == 7
replace xhappy2 = . if Q15_4_2 == .

gen xhappy3 = 0
replace xhappy3 = 1 if Q15_6_2 == 3
replace xhappy3 = . if Q15_6_2 == 7
replace xhappy3 = . if Q15_6_2 == .

gen xhappy4 = 0
replace xhappy4 = 1 if Q15_8_2 == 3
replace xhappy4 = . if Q15_8_2 == 7
replace xhappy4 = . if Q15_8_2 == .

gen xhappy5 = 0
replace xhappy5 = 1 if Q15_10_2 == 3
replace xhappy5 = . if Q15_10_2 == 1
replace xhappy5 = . if Q15_10_2 == .

* Outcome14 （Pride for the government）
gen xproud1 = 0
replace xproud1 = 1 if Q15_2_2 == 4
replace xproud1 = . if Q15_2_2 == 7
replace xproud1 = . if Q15_2_2 == .

gen xproud2 = 0
replace xproud2 = 1 if Q15_4_2 == 4
replace xproud2 = . if Q15_4_2 == 7
replace xproud2 = . if Q15_4_2 == .

gen xproud3 = 0
replace xproud3 = 1 if Q15_6_2 == 4
replace xproud3 = . if Q15_6_2 == 7
replace xproud3 = . if Q15_6_2 == .

gen xproud4 = 0
replace xproud4 = 1 if Q15_8_2 == 4
replace xproud4 = . if Q15_8_2 == 7
replace xproud4 = . if Q15_8_2 == .

gen xproud5 = 0
replace xproud5 = 1 if Q15_10_2 == 4
replace xproud5 = . if Q15_10_2 == 1
replace xproud5 = . if Q15_10_2 == .

* Outcome15 （Grief at the government ）
gen xsad1 = 0
replace xsad1 = 1 if Q15_2_2 == 5
replace xsad1 = . if Q15_2_2 == 7

gen xsad2 = 0
replace xsad2 = 1 if Q15_4_2 == 5
replace xsad2 = . if Q15_4_2 == 7

gen xsad3 = 0
replace xsad3 = 1 if Q15_6_2 == 5
replace xsad3 = . if Q15_6_2 == 7

gen xsad4 = 0
replace xsad4 = 1 if Q15_8_2 == 5
replace xsad4 = . if Q15_8_2 == 7

gen xsad5 = 0
replace xsad5 = 1 if Q15_10_2 == 5
replace xsad5 = . if Q15_10_2 == 7

* Outcome16 (No feeling for the government)
gen xna1 = 0
replace xna1 = 1 if Q15_10_2 == 6
replace xna1 = . if Q15_10_2 == 7

gen xna2 = 0
replace xna2 = 1 if Q15_4_2 == 6
replace xna2 = . if Q15_4_2 == 7

gen xna3 = 0
replace xna3 = 1 if Q15_6_2 == 6
replace xna3 = . if Q15_6_2 == 7

gen xna4 = 0
replace xna4 = 1 if Q15_8_2 == 6
replace xna4 = . if Q15_8_2 == 7

gen xna5 = 0
replace xna5 = 1 if Q15_10_2 == 6
replace xna5 = . if Q15_10_2 == 7

* Outcome21 (anger against PM) 
gen ang1=0
replace ang1 = 1 if Q15_2_1 == 1
replace ang1 = . if Q15_2_1 == 7

gen ang2=0
replace ang2 = 1 if Q15_4_1 == 1
replace ang2 = . if Q15_4_1 == 7

gen ang3=0
replace ang3 = 1 if Q15_6_1 == 1
replace ang3 = . if Q15_6_1 == 7

gen ang4=0
replace ang4 = 1 if Q15_8_1 == 1
replace ang4 = . if Q15_8_1 == 7

gen ang5=0
replace ang5 = 1 if Q15_10_1 == 1
replace ang5 = . if Q15_10_1 == 7

* Outcome22 (anxiety about PM) 
gen anx1=0
replace anx1 = 1 if Q15_2_1 == 2
replace anx1 = . if Q15_2_1 == 7

gen anx2=0
replace anx2 = 1 if Q15_4_1 == 2
replace anx2 = . if Q15_4_1 == 7

gen anx3=0
replace anx3 = 1 if Q15_6_1 == 2
replace anx3 = . if Q15_6_1 == 7

gen anx4=0
replace anx4 = 1 if Q15_8_1 == 2
replace anx4 = . if Q15_8_1 == 7

gen anx5=0
replace anx5 = 1 if Q15_10_1 == 2
replace anx5 = . if Q15_10_1 == 7

* Outcome23 （joy for PM）
gen happy1 = 0
replace happy1 = 1 if Q15_2_1 == 3
replace happy1 = . if Q15_2_1 == 7

gen happy2 = 0
replace happy2 = 1 if Q15_4_1 == 3
replace happy2 = . if Q15_4_1 == 7

gen happy3 = 0
replace happy3 = 1 if Q15_6_1 == 3
replace happy3 = . if Q15_6_1 == 7

gen happy4 = 0
replace happy4 = 1 if Q15_8_1 == 3
replace happy4 = . if Q15_8_1 == 7

gen happy5 = 0
replace happy5 = 1 if Q15_10_1 == 3
replace happy5 = . if Q15_10_1 == 1

* Outcome24 （Pride for PM）
gen proud1 = 0
replace proud1 = 1 if Q15_2_1 == 4
replace proud1 = . if Q15_2_1 == 7
replace proud1 = . if Q15_2_1 == .

gen proud2 = 0
replace proud2 = 1 if Q15_4_1 == 4
replace proud2 = . if Q15_4_1 == 7
replace proud2 = . if Q15_4_1 == .

gen proud3 = 0
replace proud3 = 1 if Q15_6_1 == 4
replace proud3 = . if Q15_6_1 == 7
replace proud3 = . if Q15_6_1 == .

gen proud4 = 0
replace proud4 = 1 if Q15_8_1 == 4
replace proud4 = . if Q15_8_1 == 7
replace proud4 = . if Q15_8_1 == .

gen proud5 = 0
replace proud5 = 1 if Q15_10_1 == 4
replace proud5 = . if Q15_10_1 == 1
replace proud5 = . if Q15_10_1 == .

* Outcome25 （Grief at PM）
gen sad1 = 0
replace sad1 = 1 if Q15_2_1 == 5
replace sad1 = . if Q15_2_1 == 7

gen sad2 = 0
replace sad2 = 1 if Q15_4_1 == 5
replace sad2 = . if Q15_4_1 == 7

gen sad3 = 0
replace sad3 = 1 if Q15_6_1 == 5
replace sad3 = . if Q15_6_1 == 7

gen sad4 = 0
replace sad4 = 1 if Q15_8_1 == 5
replace sad4 = . if Q15_8_1 == 7

gen sad5 = 0
replace sad5 = 1 if Q15_10_1 == 5
replace sad5 = . if Q15_10_1 == 7

* Outcome26 (No feeling for PM)
gen na1 = 0
replace na1 = 1 if Q15_10_1 == 6
replace na1 = . if Q15_10_1 == 7

gen na2 = 0
replace na2 = 1 if Q15_4_1 == 6
replace na2 = . if Q15_4_1 == 7

gen na3 = 0
replace na3 = 1 if Q15_6_1 == 6
replace na3 = . if Q15_6_1 == 7

gen na4 = 0
replace na4 = 1 if Q15_8_1 == 6
replace na4 = . if Q15_8_1 == 7

gen na5 = 0
replace na5 = 1 if Q15_10_1 == 6
replace na5 = . if Q15_10_1 == 7

* Outcome31 (anger against enemy) 
gen eang1=0
replace eang1 = 1 if Q15_2_3 == 1
replace eang1 = . if Q15_2_3 == 7
replace eang1 = . if Q15_2_3 == .

gen eang2=0
replace eang2 = 1 if Q15_4_3 == 1
replace eang2 = . if Q15_4_3 == 7
replace eang2 = . if Q15_4_3 == .

gen eang3=0
replace eang3 = 1 if Q15_6_3 == 1
replace eang3 = . if Q15_6_3 == 7
replace eang3 = . if Q15_6_3 == .

gen eang4=0
replace eang4 = 1 if Q15_8_3 == 1
replace eang4 = . if Q15_8_3 == 7
replace eang4 = . if Q15_8_3 == .

gen eang5=0
replace eang5 = 1 if Q15_10_3 == 1
replace eang5 = . if Q15_10_3 == 7
replace eang5 = . if Q15_10_3 == .

* Outcome32 (anxiety about enemy) 
gen eanx1=0
replace eanx1 = 1 if Q15_2_3 == 2
replace eanx1 = . if Q15_2_3 == 7
replace eanx1 = . if Q15_2_3 == .

gen eanx2=0
replace eanx2 = 1 if Q15_4_3 == 2
replace eanx2 = . if Q15_4_3 == 7
replace eanx2 = . if Q15_4_3 == .

gen eanx3=0
replace eanx3 = 1 if Q15_6_3 == 2
replace eanx3 = . if Q15_6_3 == 7
replace eanx3 = . if Q15_6_3 == .

gen eanx4=0
replace eanx4 = 1 if Q15_8_3 == 2
replace eanx4 = . if Q15_8_3 == 7
replace eanx4 = . if Q15_8_3 == .

gen eanx5=0
replace eanx5 = 1 if Q15_10_3 == 2
replace eanx5 = . if Q15_10_3 == 7
replace eanx5 = . if Q15_2_3 == .

* Outcome33 （joy for enemy）
gen ehappy1 = 0
replace ehappy1 = 1 if Q15_2_3 == 3
replace ehappy1 = . if Q15_2_3 == 7

gen ehappy2 = 0
replace ehappy2 = 1 if Q15_4_3 == 3
replace ehappy2 = . if Q15_4_3 == 7

gen ehappy3 = 0
replace ehappy3 = 1 if Q15_6_3 == 3
replace ehappy3 = . if Q15_6_3 == 7

gen ehappy4 = 0
replace ehappy4 = 1 if Q15_8_3 == 3
replace ehappy4 = . if Q15_8_3 == 7

gen ehappy5 = 0
replace ehappy5 = 1 if Q15_10_3 == 3
replace ehappy5 = . if Q15_10_3 == 1

* Outcome34 （Pride for enemy）
gen eproud1 = 0
replace eproud1 = 1 if Q15_2_3 == 4
replace eproud1 = . if Q15_2_3 == 7

gen eproud2 = 0
replace eproud2 = 1 if Q15_4_3 == 4
replace eproud2 = . if Q15_4_3 == 7

gen eproud3 = 0
replace eproud3 = 1 if Q15_6_3 == 4
replace eproud3 = . if Q15_6_3 == 7

gen eproud4 = 0
replace eproud4 = 1 if Q15_8_3 == 4
replace eproud4 = . if Q15_8_3 == 7

gen eproud5 = 0
replace eproud5 = 1 if Q15_10_3 == 4
replace eproud5 = . if Q15_10_3 == 1

* Outcome35 （Grief at enemy）
gen esad1 = 0
replace esad1 = 1 if Q15_2_3 == 5
replace esad1 = . if Q15_2_3 == 7

gen esad2 = 0
replace esad2 = 1 if Q15_4_3 == 5
replace esad2 = . if Q15_4_3 == 7

gen esad3 = 0
replace esad3 = 1 if Q15_6_3 == 5
replace esad3 = . if Q15_6_3 == 7

gen esad4 = 0
replace esad4 = 1 if Q15_8_3 == 5
replace esad4 = . if Q15_8_3 == 7

gen esad5 = 0
replace esad5 = 1 if Q15_10_3 == 5
replace esad5 = . if Q15_10_3 == 7

* Outcome36 (No feeling for enemy)
gen ena1 = 0
replace ena1 = 1 if Q15_2_3 == 6
replace ena1 = . if Q15_2_3 == 7
replace ena1 = . if Q15_2_3 == .

gen ena2 = 0
replace ena2 = 1 if Q15_4_3 == 6
replace ena2 = . if Q15_4_3 == 7
replace ena2 = . if Q15_4_3 == .

gen ena3 = 0
replace ena3 = 1 if Q15_6_3 == 6
replace ena3 = . if Q15_6_3 == 7
replace ena3 = . if Q15_6_3 == .

gen ena4 = 0
replace ena4 = 1 if Q15_8_3 == 6
replace ena4 = . if Q15_8_3 == 7
replace ena4 = . if Q15_8_3 == .

gen ena5 = 0
replace ena5 = 1 if Q15_10_3 == 6
replace ena5 = . if Q15_10_3 == 7
replace ena5 = . if Q15_10_3 == .

*Long format
reshape long enemy area death protected security ally ///
out ang anx proud happy sad na ///
xang xanx xproud xhappy xsad xna ///
eang eanx eproud ehappy esad ena, i(id) j(task)

**************************************************
 
*making dummy variables in Long format
xi i.enemy i.area i.death i.protected i.security i.ally, pre(c) noomit

*labelling variables
gen Iran = cenemy_0
gen Hamas = cenemy_1
gen Hizbullah = cenemy_2
gen TelAviv = carea_0
gen Border = carea_1
gen Jerusalem = carea_2
gen dead0 = cdeath_0
gen dead1 = cdeath_1
gen dead10 = cdeath_2
gen dead100 = cdeath_3
gen innocent = cprotected_0
gen Jews = cprotected_1
gen Israelis = cprotected_2
gen WorldOrder = cprotected_3
gen NationalSecurity = csecurity_0
gen RegionalSecurity = csecurity_1
gen NoAlly = cally_0
gen USAlly = cally_1
gen AngerEnemy = eang
gen AnxietyEnemy = eanx

*outcome
gen outcome = out
recode outcome(1=4)(2=3)(3=2)(4=1)(5 6 7=.)

*clustering in id
xtset id

// H1 

quietly eststo m1: xtlogit eang Iran Hizbullah TelAviv Jerusalem dead1 dead10 dead100 Jews Israelis WorldOrder NationalSecurity USAlly, re vce(cluster id)

quietly eststo m2: xtlogit eanx Iran Hizbullah TelAviv Jerusalem dead1 dead10 dead100 Jews Israelis WorldOrder NationalSecurity USAlly, re vce(cluster id)

quietly eststo m3: xtlogit ena Iran Hizbullah TelAviv Jerusalem dead1 dead10 dead100 Jews Israelis WorldOrder NationalSecurity USAlly, re vce(cluster id)

// H1c & H2

quietly eststo m5: xtlogit proud AngerEnemy AnxietyEnemy Iran Hizbullah TelAviv Jerusalem dead1 dead10 dead100 Jews Israelis WorldOrder NationalSecurity USAlly, re vce(cluster id)

quietly eststo m6: xtlogit xproud AngerEnemy AnxietyEnemy Iran Hizbullah TelAviv Jerusalem dead1 dead10 dead100 Jews Israelis WorldOrder NationalSecurity USAlly, re vce(cluster id)

quietly eststo m4: xtreg outcome AngerEnemy AnxietyEnemy Iran Hizbullah TelAviv Jerusalem dead1 dead10 dead100 Jews Israelis WorldOrder NationalSecurity USAlly, re vce(cluster id)

coefplot(m1, label("Anger")) ,bylabel([A] Anger-Enemy)  ///
||(m2, label("Anxiety")) ,bylabel([B] Anxiety-Enemy)  ///
||(m3, label("No Feeling")),bylabel([C] No Feeling)   ///
||(m4, label("RRTF Proud of PM")),bylabel([D] RRTF)   ///
||(m5, label("Proud of PM")),bylabel([E] Proud of PM)   ///
||(m6, label("Proud of Gov")), bylabel([F] Proud of Gov) ///
 xline(0,lc(black) lpattern(dash) lwidth(*1)) ///
 drop(_cons) omitted baselevels ///
 headings(Iran = {bf:Enemy(base:Hamas)} ///
 TelAviv = {bf:Area(base:Border)} ///
 dead1 = {bf:Death(base:dead0)} ///
 Jews = {bf:Threat(base:innocent)} ///
 NationalSecurity = {bf:Security(base:RegionalSecurity)} ///
 USAlly = {bf:Ally(base:NoAlly)} ///
 AngerEnemy ={bf:Anger-Enemy} ///
 AnxietyEnemy ={bf:Anxiety-Enemy}, ///
 labcolor(black) labgap(.5)labsize(vsmall)) ///
 grid(between glcolor(white))mfcolor(white) ///
 ylabel(,labsize(vsmall) labcolor(black)) legend(off) ///
 xlabel(,labsize(vsmall)) ///
 ciopts(lcolor(blue)) ///
 xsize(20)ysize(10)  byopts(xrescale cols(6)) ///
 xtitle("Rally round the flag in Israel")
 
